package org.lanqiao.tjut.dao;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.lanqiao.tjut.bean.UsersBean;
import org.lanqiao.tjut.db.DBDriverFactory;

public class LoginDao {

	/**
	 * 用户登录验证
	 * 
	 * @param usersB
	 *            用户信息实体对象
	 * @return 登录验证结果
	 */
	public boolean isLogined(UsersBean usersB) {
		boolean isL = false;
		// 登录验证sql语句
		String strSql = "SELECT * FROM EDUUSERS WHERE USERNAME = ? AND USERPSW = ? AND USERST=?";
		List<UsersBean> lstUsers = DBDriverFactory.getDBDriverInstance().query(strSql,
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[] { usersB.getUsername(), usersB.getUserpsw(),usersB.getUserst() });
		// 根据查询结果判定用户是否登录成功
		if (lstUsers != null && lstUsers.size() > 0) {
			// 登录验证成功
			isL = true;
		}
		return isL;
	}

	/**
	 * 用户登录验证
	 * 
	 * @param usersB
	 *            用户信息实体对象
	 * @return 登录验证结果信息
	 */
	public List<UsersBean> isLogined2(UsersBean usersB) {
		// 登录验证sql语句
		String strSql = "SELECT * FROM EDUUSERS WHERE USERNAME = ? AND USERPSW = ? AND USERST=?";
		List<UsersBean> lstUsers = DBDriverFactory.getDBDriverInstance().query(strSql,
				new BeanListHandler<UsersBean>(UsersBean.class),
				new Object[] { usersB.getUsername(), usersB.getUserpsw(),usersB.getUserst() });

		return lstUsers;
	}
}
